<template>
	<view>
		<text>\n</text>
		<input style="background: #808080;" v-model="name" />
		<button @click="search()" style="">搜索</button>
		<text>\n</text>
		<text v-for="(item,i) in files" :key="i">
			&nbsp;&nbsp;&nbsp;{{item.name}}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<button @click="download(item.url,item.name)" style="width: 100px;height:30px ;line-height: 30px;margin-right: 1px;margin-top: -20px;">下载</button>
			<text style="color: #999999;">——————————————————————————————</text>
		</text>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				files:{},
				name:""
			}
		},
		onShow() {
			uni.request({
			method:"GET",
			url:this.requestUrl+"/ForeFile/fileList",
			success:response=>{
				this.files=response.data;
			}	
			})
		}
		,
		methods: {
			download(url,name){
				var history=uni.getStorageSync("history");
				if(history==""){
					history=[];
				}
				history.push({"name":name,"url":url});
				uni.setStorageSync("history",history);
				
				uni.setStorageSync("prefileUrl",url);
				uni.navigateTo({url:'../preview/preview'});
			},
			search(){
				uni.request({
				method:"GET",
				url:this.requestUrl+"/ForeFile/fileList?name="+this.name,
				success:response=>{
					this.files=response.data;
				}	
				})
			}
		}
	}
</script>

<style>

</style>
